from flask_restful import Api
from .user import UserAPI, UserListAPI
from .question import QuestionAPI, QuestionListAPI

# 资源配置元组
DEFAULT_RESOURCE = (
    (UserAPI, '/user/<int:uid>'),
    (UserListAPI, '/user/'),
    (QuestionAPI, '/question/<int:qid>'),
    (QuestionListAPI, '/question/'),
)


def config_resource(app):
    api = Api(app)
    for resource, url in DEFAULT_RESOURCE:
        api.add_resource(resource, url)
